/**************************************************************************************************
	$Header: /pub/cvsroot/mydns/src/lib/str.c,v 1.3 2002/06/18 12:57:08 bboy Exp $

	Copyright (C) 2002  Don Moore <bboy@bboy.net>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at Your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**************************************************************************************************/

#include "mydns.h"


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_CLASS_STR
	Returns a pointer to a static string describing the specified query/response protocol class.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_class_str(c)
	int c;
{
	static char buf[80];

	switch (c)
	{
		case DNS_C_IN:     return ("IN");
		case DNS_C_CHAOS:  return ("CHAOS");
		case DNS_C_HESIOD: return ("HESIOD");
		case DNS_C_ANY:    return ("ANY");
	}
	snprintf(buf, sizeof(buf), "UNK%03d", c);
	return (buf);
}
/*--- mydns_class_str() -------------------------------------------------------------------------*/


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_QTYPE_STR
	Returns a pointer to a static string describing the specified query/response type.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_qtype_str(qtype)
	dns_qtype_t qtype;
{
	static char buf[80];

	switch (qtype)
	{
		case DNS_T_A:     return ("A");
		case DNS_T_NS:    return ("NS");
		case DNS_T_CNAME: return ("CNAME");
		case DNS_T_SOA:   return ("SOA");
		case DNS_T_NULL:  return ("NULL");
		case DNS_T_PTR:   return ("PTR");
		case DNS_T_HINFO: return ("HINFO");
		case DNS_T_MINFO: return ("MINFO");
		case DNS_T_MX:    return ("MX");
		case DNS_T_TXT:   return ("TXT");
		case DNS_T_IXFR:  return ("IXFR");
		case DNS_T_AXFR:  return ("AXFR");
		case DNS_T_ANY:   return ("ANY");
		default: break;
	}
	snprintf(buf, sizeof(buf), "%03d", qtype);
	return (buf);
}
/*--- mydns_qtype_str() -------------------------------------------------------------------------*/


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_OPCODE_STR
	Returns a pointer to a static string describing the specified query/response opcode.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_opcode_str(opcode)
	dns_opcode_t opcode;
{
	static char buf[80];

	switch (opcode)
	{
		case DNS_OPCODE_QUERY:  return ("QUERY");
		case DNS_OPCODE_IQUERY: return ("IQUERY");
		case DNS_OPCODE_STATUS: return ("STATUS");
	}
	snprintf(buf, sizeof(buf), "%03d", opcode);
	return (buf);
}
/*--- mydns_opcode_str() ------------------------------------------------------------------------*/


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_RCODE_STR
	Returns a pointer to a static string describing the specified return code.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_rcode_str(rcode)
	dns_rcode_t rcode;
{
	static char buf[80];

	switch (rcode)
	{
		case DNS_R_OK:       return ("OK");
		case DNS_R_FORMERR:  return ("FORMERR");
		case DNS_R_SERVFAIL: return ("SERVFAIL");
		case DNS_R_NXDOMAIN: return ("NXDOMAIN");
		case DNS_R_NOTIMP:   return ("NOTIMP");
		case DNS_R_REFUSED:  return ("REFUSED");
	}
	snprintf(buf, sizeof(buf), "%03d", rcode);
	return (buf);
}
/*--- mydns_rcode_str() -------------------------------------------------------------------------*/

/* vi:set ts=3: */
